import config

class this_user(object):
    def __init__(self, phonenumber, username, md5):
        self.pn = phonenumber
        self.un = username
        self.md5 = md5

def verification(phonenumber, key):
    return (config.sjk.user_coll.find({"user_phone": phonenumber, "user_md5": key}).count() == 1)

def get_user_by_phonenumber(phonenumber):
    return config.sjk.user_coll.find({"user_phone":phonenumber})[0]
    # what type of .find?  A dic.

def get_user_by_id(id):
    return config.sjk.user_coll.find({'user_id':id})[0]
